home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr13 / tstse13.zip / POSTSCRI.S < prev    next >
Text File  |  1994-11-29  |  9KB  |  297 lines

  1. /* A special net postscript print for SemWare's TSE editor V2.0.
  2.    This macro is an expert's tool, and will require much more than
  3.    usual to configure it to make it work. To make this SAL macro
  4.    operational, first customize the file name and the path
  5.    constants, then invoke the main menu (F10), choose "Macro",
  6.    choose "Compile" and press Enter at "Execute Macro".
  7.  
  8. ..................................................................
  9. Prof. Timo Salmi      Co-moderator of comp.archives.msdos.announce
  10. Moderating at garbo.uwasa.fi anonymous FTP archives  193.166.120.5
  11. Faculty of Accounting & Industrial Management; University of Vaasa
  12. Internet: ts@uwasa.fi   BBS +(358)-61-3170972; FIN-65101,  Finland
  13. */
  14.  
  15. // The contents of a simple help, tied later to the CtrlAlt-H key
  16. helpdef tHelpData
  17.   title = "POSTSCRI.S HELP"       // The help's caption
  18.   x = 10                          // Location
  19.   y = 3
  20.   // The actual help text
  21.   " Prof. Timo Salmi's use net postscript printers. "
  22.   ""
  23.   " This macro is an expert's tool and may require "
  24.   " careful customizing and acquisitions before you "
  25.   " can utilize it. "
  26.   ""
  27.   " You can use <F11> to invoke the command menu after "
  28.   " first exiting this help. "
  29.   ""
  30.   " Last updated Tue 29-November-1994 09:28:06 "
  31. end  /* tHelpData */
  32.  
  33. // Initializations
  34. //
  35. integer font_size = 25
  36. string font_type[20] = "NCSB"
  37. string printer_choice[20] = "lt"           // Customize as appropriate
  38. //
  39. integer left_margin_hist
  40. integer line_spacing_hist
  41. integer font_size_hist
  42. //
  43. string ramDiskPath[80] = "r:\"             // Customize as appropriate
  44. string ramFilePath[80] = "ts$$.prn"        // Customize as appropriate
  45. //
  46. string pcpsProg[80] = "c:\box\boxtools\pcps.exe" // Customize as appropriate
  47. //
  48. string lprDrive[1]  // Customize as appropriate in proc Main()
  49. string lprPath[80]  = "\progs\telecsv"   // Customize as appropriate
  50.  
  51. // Check that you have the right PC, customize as appropriate
  52. // You'll need a "set pcid_=YourId" in you autoexec.bat
  53. integer proc CheckPC()
  54.   case GetEnvStr("PCID_")
  55.     when "karvi","osku" Return (TRUE)  // Customize as appropriate
  56.   endcase
  57.   Warn("The macro is not for this PC, see CheckPC()" )
  58.   Return(FALSE)
  59. end CheckPC
  60.  
  61. // Check that the ramdisk is available
  62. integer proc CheckRamDisk()
  63.   integer key
  64.   //
  65.   if FileExists(ramDiskPath) Return(TRUE) endif
  66.   PopWinOpen(2,3,74,8, 1, "Warning", Color(BRIGHT Red ON Black))
  67.   Set(Attr, Color(BRIGHT Magenta ON Black))
  68.   ClrScr()
  69.   Writeline('Ramdisk directory ', ramDiskPath, ' was not found!')
  70.   Set(Attr, Color(BRIGHT Yellow ON Black))
  71.   Writeline('You either need to edit and recompile the macro to point to an existing')
  72.   Writeline('drive, or create an appropriate ramdisk.')
  73.   Set(Attr, Color(BRIGHT Green ON Black))
  74.   Write ('Press esc ... ')
  75.   key = GetKey()
  76.   PopWinClose()
  77.   Return(FALSE)
  78. end CheckRamDisk
  79.  
  80. // Check that the postscript program is available
  81. integer proc CheckPCPSprog()
  82.   integer key
  83.   //
  84.   if FileExists(pcpsProg) Return(TRUE) endif
  85.   PopWinOpen(2,3,79,8, 1, "Warning", Color(BRIGHT Red ON Black))
  86.   Set(Attr, Color(Cyan ON Black))
  87.   ClrScr()
  88.   Writeline('File ', pcpsProg, ' was not found!')
  89.   Set(Attr, Color(BRIGHT Yellow ON Black))
  90.   Writeline('You need it from garbo.uwasa.fi:/pc/postscript/pcps792.zip for running')
  91.   Writeline('this macro. If you already have it, adjust your path to it.')
  92.   Set(Attr, Color(BRIGHT Green ON Black))
  93.   Write ('Press esc ... ')
  94.   key = GetKey()
  95.   PopWinClose()
  96.   Return(FALSE)
  97. end CheckPCPSprog
  98.  
  99. // Check that program to send a job to a remote printer is available
  100. integer proc CheckLPRprog()
  101.   integer key
  102.   //
  103.   if FileExists(lprDrive + ":" + lprPath + "\lpr.exe")
  104.     Return(TRUE)
  105.   endif
  106.   PopWinOpen(2,3,79,8, 1, "Warning", Color(BRIGHT Red ON Black))
  107.   Set(Attr, Color(Cyan ON Black))
  108.   ClrScr()
  109.   Writeline("File ", lprDrive + ":" + lprPath, "\lpr.exe was not found!")
  110.   Set(Attr, Color(BRIGHT Yellow ON Black))
  111.   Writeline('You need it from garbo.uwasa.fi:/pc/connect/tel2308b.zip for running')
  112.   Writeline('this macro. If you already have it, adjust your path to it.')
  113.   Set(Attr, Color(BRIGHT Green ON Black))
  114.   Write ('Press esc ... ')
  115.   key = GetKey()
  116.   PopWinClose()
  117.   Return(FALSE)
  118. end CheckLPRprog
  119.  
  120. /*
  121. Returns the current directory, minus the trailing slash (unless
  122. root) without the drive name. Based on a procedure by Ian Campbell.
  123. */
  124. string proc tCurrDir()
  125.   string s[80]
  126.   s = SplitPath(ExpandPath(""), _PATH_)
  127.   if Length(s) > 1
  128.     s = SubStr(s, 1, Length(s) - 1)
  129.   endif
  130.   return(s)
  131. end tCurrDir
  132.  
  133. // Print all to lt/mt printer
  134. proc tPrintAllToLT()
  135.   string s[80] = ""
  136.   string pushDrive[1]
  137.   string pushDir1[80]
  138.   string pushDir2[80]
  139.   //
  140.   s = pcpsProg + " -nb -mal60 -mar1 -fo" + font_type + Str(font_size) + " " + CurrFileName() + " > r:\ts$$.ps"
  141.   //
  142.   pushDir1 = tCurrDir()
  143.   pushDrive = GetDrive()
  144.   LogDrive(lprDrive)
  145.   pushDir2 = tCurrDir()
  146.   ChDir(lprPath)
  147.   //
  148.   Dos (s)
  149.   Dos ("lpr -P" + printer_choice + " -Schyde r:\ts$$.ps", _DONTPROMPT_)
  150.   Dos ("del r:\ts$$.ps", _DONTPROMPT_)
  151.   Message (CurrFileName() + " processed and sent to " + printer_choice + " printer")
  152.   //
  153.   ChDir(pushDir2)
  154.   LogDrive(pushDrive)
  155.   ChDir(pushDir1)
  156. end tPrintAllToLT
  157.  
  158. // Print block to lt/mt printer
  159. proc tPrintBlockToLT()
  160.   string s[80] = ""
  161.   string pushDrive[1]
  162.   string pushDir1[80]
  163.   string pushDir2[80]
  164.   //
  165.   if isBlockInCurrFile()
  166.     PushPosition()
  167.     PushBlock()
  168.     SaveBlock(ramDiskPath + ramFilePath)
  169.     //
  170.     s = pcpsProg + " -nb -mal60 -mar1 -fo" + font_type + Str(font_size) + " " + ramDiskPath + ramFilePath + " > r:\ts$$.ps"
  171.     //
  172.     pushDir1 = tCurrDir()
  173.     pushDrive = GetDrive()
  174.     LogDrive(lprDrive)
  175.     pushDir2 = tCurrDir()
  176.     ChDir(lprPath)
  177.     //
  178.     Dos (s)
  179.     Dos ("lpr -P" + printer_choice + " -Schyde r:\ts$$.ps", _DONTPROMPT_)
  180.     Dos ("del r:\ts$$.ps", _DONTPROMPT_)
  181.     Message ("Block processed and sent to " + printer_choice + " printer")
  182.     //
  183.     ChDir(pushDir2)
  184.     LogDrive(pushDrive)
  185.     ChDir(pushDir1)
  186.     //
  187.     EraseDiskFile(ramDiskPath + ramFilePath)
  188.     PopBlock()
  189.     PopPosition()
  190.   else
  191.     Warn("No Block")
  192.   endif
  193. end tPrintBlockToLT
  194.  
  195. proc tSetLTFonSize()
  196.   string vast[11] = Str(font_size)
  197.   Ask("Font size: ", vast, font_size_hist)
  198.   AddHistoryStr (vast, font_size_hist)
  199.   font_size = Val(vast)
  200. end tSetLTFonSize
  201.  
  202. // New keys and menus **************************************************
  203. forward Menu tPrintToLanMenu()
  204. forward proc timoDisableNewKeys()
  205.  
  206. // Add the new key definitions
  207. keydef new_keys
  208.   <CtrlAlt 0>      timoDisableNewKeys()
  209.   <CtrlAlt H>      QuickHelp(tHelpData)
  210.   <F11>            tPrintToLanMenu()
  211. end
  212.  
  213. // Disable the new extra keys ****************************************
  214. proc timoDisableNewKeys()
  215.   if YesNo("Disable the extra keys:") == 1
  216.     Disable(new_keys)
  217.     DelHistory(font_size_hist)
  218.     DelHistory(line_spacing_hist)
  219.     DelHistory(left_margin_hist)
  220.   endif
  221. end
  222.  
  223. proc tSetFont(integer choice)
  224.   case choice
  225.     when 1 font_type = "NCSB"
  226.     when 2 font_type = "CB"
  227.   endcase
  228. end tSetFont
  229.  
  230. proc tChoosePrinter(integer choice)
  231.   case choice
  232.     when 1 printer_choice = "lt"
  233.     when 2 printer_choice = "mt"
  234.   endcase
  235. end tChoosePrinter
  236.  
  237. // Select the font type for lt/mt printer
  238. Menu tSetLTFonTypeMenu()
  239.   Title = "Font type"
  240.   x = 62
  241.   y = 16
  242.   history
  243.   "&NCSB" , tSetFont(1)
  244.   "&CB"   , tSetFont(2)
  245. end /* tSetLTFonTypeMenu */
  246.  
  247. // The printer choice for lt/mt printer
  248. Menu tChoosePrinterMenu()
  249.   Title = "Choose lt/mt"
  250.   x = 62
  251.   y = 17
  252.   history
  253.   "<" , tChoosePrinter(1)
  254.   "&mt" , tChoosePrinter(2)
  255. end /* tChoosePrinterMenu */
  256.  
  257. // The tPrintToLan menu ***********************************************
  258. Menu tPrintToLanMenu()
  259.   Title = "Timo's net print menu"
  260.   Width = 19
  261.   x = 40
  262.   y = 3
  263.   history
  264.   "Print all to l&t/mt-printer"        , tPrintAllToLT()
  265.   "P&rint block to lt/mt-printer"      , tPrintBlockToLT()
  266.   "",,Divide
  267.   "Set lt/mt &font size ..."           , tSetLTFonSize()     , DontClose
  268.   "Set lt/mt font t&ype "             , tSetLTFonTypeMenu() , DontClose
  269.   "Choose lt&/mt printer "            , tChoosePrinterMenu(), DontClose
  270.   "",,Divide
  271.   "Disable &new keys  <CtrlAlt 0>"     , timoDisableNewKeys()
  272.   "&Help              <CtrlAlt H>"     , QuickHelp(tHelpData)
  273.   "This Menu         <F11>"
  274. end  /* tPrintToLanMenu */
  275.  
  276. proc Main()
  277.   //
  278.   if GetEnvStr("PCID_") == "karvi"
  279.     lprDrive = "f"
  280.   elseif GetEnvStr("PCID_") == "osku"
  281.     lprDrive = "d"
  282.   else
  283.     lprDrive = "c"    // Customize as appropriate
  284.   endif
  285.   //
  286.   if not CheckPC()       goto _endproc endif
  287.   if not CheckPCPSprog() goto _endproc endif
  288.   if not CheckLPRprog()  goto _endproc endif
  289.   if not CheckRamDisk()  goto _endproc endif
  290.   left_margin_hist  = GetFreeHistory()
  291.   line_spacing_hist = GetFreeHistory()
  292.   font_size_hist    = GetFreeHistory()
  293.   Enable (new_keys)
  294.   tprintToLanMenu()
  295. _endproc:
  296. end
  297.